<%@ page import="java.sql.Date"%>
<%@ page import="si.sp.socialnetwork.DatabaseBean"%>
7<%@ page import="si.sp.socialnetwork.User"%>

<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>

<%
	request.setCharacterEncoding("UTF-8");
	response.setCharacterEncoding("UTF-8");
    
    String email = request.getParameter("registration_email");
	String geslo = request.getParameter("registration_password");
	String ime = request.getParameter("name");
	String priimek = request.getParameter("surname");
    
	String spol;
	String selected_radio = request.getParameter("gender");
    if (selected_radio == "male") {
    	spol = "moski";
    }  else if (selected_radio == "female") {
    	spol = "zenski";
    } else{
    	spol = "neznan";   
    }

    Date rd;
    int day = 10;
    int month = 10;
    int year = 1980;
    rd = new Date(year, month, day);
	
    String kraj = request.getParameter("place");

	if (email == null) {
		email = "";
	}
	if (geslo == null) {
		geslo = "";
	}
	if (ime == null) {
		ime = "";
	}
	if (priimek == null) {
		priimek = "";
	}
	if (kraj == null) {
		kraj = "";
	}

	
	if (!email.equals("") && !geslo.equals("") && !ime.equals("")
			&& !priimek.equals("")
			&& !kraj.equals("")) {

	    User user = new User(email, geslo, ime, priimek, kraj, spol, rd);
        
		DatabaseBean db_bean = new DatabaseBean();
        boolean success = db_bean.setUser(user);
        if (success) {
        	response.sendRedirect("index.jsp");
        } else {
            
        }
        
	} else {
		response.sendRedirect("index.jsp");
	}
%>